package tec;


abstract class PassagerAbstrait 
    extends Passager
    implements  Usager{
    
 
    
    private final String nom;
    private final int destination;
    private EtatPassager monEtat;
    private Caractere c;
    
    
    public PassagerAbstrait(String nom, int destination, Caractere c){
	this.nom = nom;
	this.destination = destination;
	this.c = c;
	monEtat = EtatPassager.DEHORS;
    }

    final boolean plusCinqArrets(int numeroArret){
	return (numeroArret <= this.destination - 5);
    }

    final boolean moinsTroisArrets(int numeroArret){
	return (numeroArret >= this.destination - 3);
    }

    
    
    public final String nom() {
	return this.nom;
    }

    final boolean estDehors() {
	return monEtat.estExterieur();
    }

    final boolean estAssis(){
	return monEtat.estAssis();
    }

    final boolean estDebout() {
	return monEtat.estDebout();
    }

    final void accepterSortie() {
	monEtat = EtatPassager.DEHORS;
    }

    final void accepterPlaceAssise() {
	monEtat = EtatPassager.ASSIS;
	
    }

    final void accepterPlaceDebout() {
	monEtat = EtatPassager.DEBOUT;
    }


    final void nouvelArret(Bus b, int numeroArret) {
	
	
	if(this.destination <= numeroArret)
	    b.demanderSortie(this);
	c.choixChangerPlace(b, numeroArret,this);
    }
    
    public final void monterDans(Transport t) { 
	Bus b = (Bus) t;
	choixPlaceMontee(b);
    }
    
    abstract protected void choixPlaceMontee(Bus b);
   
   

    @Override
	public String toString() {
	
	return nom() + " " + monEtat.toString();
    }
}

